#ifndef MODELING_PERSPECTIVE_H
#define MODELING_PERSPECTIVE_H

#include <editorarea.h>
#include <iperspective.h>

#include <QtGui/QMainWindow>

QT_BEGIN_NAMESPACE
class QUndoView;
QT_END_NAMESPACE

namespace gui
{
class EditorGallery;
class PropertyEditor;
}

namespace swp
{
class ModelValidatorView;
class PerspectiveManager;
class ProjectNavigator;

class ModelingPerspective : public QMainWindow, public core::IPerspective
{
    Q_OBJECT

public:
    ModelingPerspective(PerspectiveManager* manager = 0, QWidget* parent = 0);
    ~ModelingPerspective();

    // IPerspective
    QList<QAction* > getStaticActions(const QString& menuId) const;
    QList<QAction* > getContextActions(const QString& menuId) const;
    QList<QToolBar* > getStaticToolBars() const;
    QList<QToolBar* > getContextToolBars() const;

    QList<QAction* > getPerspectiveEnsuringActions() const;

    core::IEditorArea* getEditorArea() const;

    bool canOpen(const core::MimeType& type) const;

    void handleIsCurrentChanged(bool current);

    void readSettings(QSettings* settings);
    void writeSettings(QSettings* settings) const;

    ProjectNavigator* projectNavigator() const;
    gui::EditorGallery* gallery() const;
    gui::PropertyEditor* propertyEditor() const;

private:
    void createActions();
    void createCentralWidget();
    void createDockWidgets();
    void createToolBars();
    void connectSlots();

private slots:
    void connectPropertyEditor(
        const QSharedPointer<core::IEditor>& editor);
    void disconnectPropertyEditor(
        const QSharedPointer<core::IDocument>& document);
    void notifyPropertyEditor(core::IGraphicEditorItem* item);
    void resetPropertyEditor(const QSharedPointer<core::IEditor>& editor);
    void expandReport();
    void highlightDocument(const QSharedPointer<core::IDocument>& document);

private:
    PerspectiveManager* m_manager;
    QDockWidget* m_projectNavigatorDock;
    QDockWidget* m_galleryDock;
    QDockWidget* m_historyDock;
    QDockWidget* m_propertyEditorDock;
    QDockWidget* m_validatorViewDock;
    ProjectNavigator* m_projectNavigator;
    gui::EditorGallery* m_gallery;
    QUndoView* m_history;
    gui::PropertyEditor* m_propertyEditor;
    ModelValidatorView* m_validatorView;
    gui::EditorArea* m_editorArea;

    QToolBar* m_projectToolbar;

    QAction* m_viewSeparator;

    // Project menu
    QAction* m_newProjectMenuAction;
    QAction* m_openProjectMenuAction;
    QAction* m_closeProjectMenuAction;
    QAction* m_saveProjectMenuAction;

    // Project toolbar
    QAction* m_newProjectAction;
    QAction* m_openProjectAction;
    QAction* m_closeProjectAction;
    QAction* m_saveProjectAction;

    QList<core::IDocumentData* > m_connectedToPropertyEditor;
};

} // namespace swp

#endif
